package files;

import java.io.File;
import java.io.FilenameFilter;

public class ImageFilter implements FilenameFilter{
	private String[] file_types;
	
	public ImageFilter(String[] types) {
		file_types = types;
	}

	@Override
	public boolean accept(File dir, String name) {
		String[] parts = name.split("\\.");
		if(parts.length == 1)
			return false;
		
		String ext = parts[parts.length-1];
		
		for(int i = 0; i < file_types.length; i++) {
			if(ext.toLowerCase().equals(file_types[i].toLowerCase()))
				return true;
		}
		
		return false;
	}
}
